import { defineStore } from 'pinia'
import {
  getToken,
  getRoleKey
} from '@/utils/auth'

export const useUserStore = defineStore({
  id: 'userStore',
  state: () => ({
    token: getToken(),
    avatarUrl: 'https://thirdwx.qlogo.cn/mmopen/vi_32/5XtTKNI6jSHKnW9QE1rsicBp2M6QTorlXoEh4vvcMI77Owv7y8kLopicLgKibvrhl7U4KdXb09VcxmcWoYiaztORLA/132',
    userId: '12345',
    userName: '',
    userGender: 0,
    roles: getRoleKey() || []
  }),
  actions: {
    logout() {
      return new Promise((resolve) => {
        location.reload()
        resolve({})
      })
    }
  }
})
